home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / MUBBS etc.cpt / Module Source / E-mail / DisplayEmail.c < prev    next >
Text File  |  1991-11-21  |  4KB  |  135 lines

  1. /* *********************************************************************************
  2.      
  3.       MODULE:        DisplayEmail Module
  4.       
  5.      DESCRIPTION:    This DisplayEmail Module is a simple module for MUBBS, the
  6.                      Multi-User Bulliten Board System Software.
  7.                      
  8.      AUTHOR:        Noam Freedman
  9.      
  10.      Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
  11.  
  12.      This program source code and it's compiled version IS NOT IN THE
  13.      PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
  14.      regarding use of this program source code and it's compiled version.
  15.      
  16.      Revision History:
  17.      ============================================================
  18.       8/26/91 - Started programming
  19.      11/ 4/91 - Edited for release
  20.      ============================================================
  21.      
  22.  
  23.     ******************************************************************************** */
  24.  
  25.  
  26. #define        INMAIN
  27.  
  28.  
  29. #include    "MUBBS Module.h"
  30. #include    "Email.h"
  31. #include    <SetUpA4.h>
  32.  
  33. /* my globals for this module */
  34.  
  35.  
  36. pascal void main (mode1,G1,P1)
  37.        int mode1;
  38.        struct GS *G1;
  39.        Ptr P1;
  40. {
  41. Handle temph;
  42. float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
  43. RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
  44. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
  45.  
  46. G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
  47. mode[u]=mode1; /* set up our mode so that you can read it anywhere */
  48.  
  49. switch (mode[u]) { /* any un-handled modes return error from this module */
  50.     case 3:
  51.         loademail(P1); /* mode 3 because we are passed a pointer */
  52.         G->moduleresult=0;
  53.         break;
  54.     case 98:
  55.         versionck(version); /* just return after this call, don't modify anything */
  56.         break;        
  57.     case 0:
  58.         strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
  59.         G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
  60.         break;
  61.     default:
  62.         G->moduleresult=1; /* return bad code */
  63.     };
  64.  
  65. HUnlock(temph); /* unlocks this module, do this ! */
  66. RestoreA4(); /* call this when you are all done */
  67. }
  68.  
  69.  
  70. loademail(S)
  71. struct LoadStruct *S;
  72. {
  73. char pad[100]; /* this is a fix for a problem */
  74. struct MsgStruct MsgInfo;
  75. struct FixStruct fixinfo;
  76. FILE *fp_headers, *fp_data;
  77. int i = 0, r, num, b,x;
  78. char ch;
  79. size_t fix;
  80.  
  81. if (!G->online[u]) { num = 2;goto byebye; } /* do this check so we can log out if hang up */
  82.  
  83.  
  84. strcpy(MsgInfo.FromUser, S->FromUser[S->choice] );
  85. strcpy(MsgInfo.ToUser, G->username[u]);
  86. strcpy(MsgInfo.title, S->title[S->choice]);
  87. MsgInfo.status=    S->status[S->choice];
  88. strcpy(MsgInfo.NetAddress, S->NetAddress[S->choice]);
  89. MsgInfo.offset=    S->offset[S->choice];
  90. MsgInfo.length=    S->length[S->choice];
  91. strcpy(MsgInfo.DateSent, S->DateSent[S->choice]);
  92.  
  93. send("]Msg  : %i of %i]",S->choice,S->numemail);
  94. send("Title: %s]",MsgInfo.title);
  95. send("From : %s]",MsgInfo.FromUser);
  96. send("Date : %s]",MsgInfo.DateSent);
  97. send(G->CR[u]);
  98. if ( (fp_data = fopen(":msgs:email.data","r")) == NULL )
  99.     {
  100.     send("]Can't open the file: %s]",":msgs:email.data");        
  101.     num = 3;
  102.     pause();
  103.     }
  104. else
  105.     {
  106.     fseek( fp_data , S->offset[S->choice] , SEEK_SET );
  107.     fix=sizeof(fixinfo);
  108.     x = S->length[S->choice] - (fix + 2); /* don't read the "fix" stuff */
  109.                         /* sizeof +1 and S->length -1 actually */
  110.     if(x>32000) x=32000;
  111.     if(x<0) x=0;
  112.     while ( i <= x )
  113.         {
  114.         i=i+1;
  115.         if ((b = fgetc(fp_data)) != EOF)
  116.             {
  117.             if (G->okcancel[u])   if (G->cancel[u])  break;  /* check for cancel press */
  118.             ch = b & 0xFF;
  119.             if ((ch == 0x0A) || (ch == 0x0D))  send(G->CR[u]);
  120.             else G->out(ch);
  121.             }
  122.         else
  123.             {
  124.             i = x+1;
  125.             }
  126.         }    
  127.     fclose(fp_data);
  128.     num = 0;
  129.     }
  130. byebye:
  131. S->result=num;
  132. return;
  133. }
  134.  
  135.